package reflect;

import java.lang.reflect.Constructor;

/**
 * 练习:使用Student类的无参构造器和全参构造器实例化[反射方式];
 */
public class Test1 {
    public static void main(String[] args) throws Exception{
        Class cls = Class.forName("reflect.Student");
        //1.无参
        Constructor c1 = cls.getConstructor();
        Object o1 = c1.newInstance();
        System.out.println(o1);

        //2.全参
        Constructor c2 = cls.getConstructor(String.class, int.class, char.class);
        Object o2 = c2.newInstance("妲己", 18, '女');
        System.out.println(o2);
    }
}








